var VILPlusOverlay = new (function() {
	this.showContextMenu = function(event) {
		// show or hide the menuitem based on what the context menu is on
		// see http://kb.mozillazine.org/Adding_items_to_menus
		_gel("vilplus_context_config").hidden = gContextMenu.onImage;
	};
	this.init = function() {
		// load string bundle
		this.strings = _gel("vilplus-strings");
		// register processContentLoaded for any document loaded
		this.tabBrowser = _gel("content");
		this.appContent = _gel("appcontent");
		this.appContent.addEventListener("DOMContentLoaded", function(e) {
			vilplus.processContentLoaded(e);
		}, false);
		// attach to browser.xul window
		_gel("contentAreaContextMenu").addEventListener(
				"popupshowing", function(e) {
					VILPlusOverlay.showContextMenu(e);
				}, false);
	}
	this.onMenuItemCommand = function(e) {
		var title = this.strings.getString("helloMessageTitle");
		var msg = this.strings.getString("helloMessage");
		alert(e);
		if (e) {
			alert(e.target.id + ":" + msg);
		}
		var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
				.getService(Components.interfaces.nsIPromptService);
		promptService.alert(window, title, msg);
	};
	this.onToolbarButtonCommand = function(e) {
		// just reuse the function above. you can change this, obviously!
		this.onMenuItemCommand(e);
	};
});
window.addEventListener("load", function(e) {
	vilplus.onLoad(e);
	VILPlusOverlay.init();
}, false);
